#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

from oracle import logger
from oracle.common.constants import ORACLE_RESERVED_WORD, SliceConstant


class OracleSecurityCheck:

    @staticmethod
    def check_database_user_name_and_password(pid, param):
        # 用户名密码为空时，合法
        if not param:
            return True
        # 不允许长度超过32
        if len(param) > 32:
            logger.error(f"password is longer than 32 digits! pid = {pid}")
            return False
        if '"' in param:
            logger.error(f"quoted identifiers cannot contain double quotation marks! pid = {pid}")
            return False
        return True